package crp.services.api.graphql.models;

import crp.core.workflow.domain.models.WorkflowTaskEntity;
import crp.core.workflow.domain.models.WorkflowTaskStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import org.eclipse.microprofile.graphql.Id;
import org.eclipse.microprofile.graphql.Type;

import javax.validation.constraints.NotNull;
import java.time.Instant;

@Type("WorkflowTask")
@Builder
@Getter
@AllArgsConstructor
public class WorkflowTaskPayload {
    @Id
    @NotNull
    private final String id;
    @NotNull
    private WorkflowTaskStatus status;
    @NotNull
    private String instanceId;
    @NotNull
    private Instant updatedAt;



    public static WorkflowTaskPayload of(WorkflowTaskEntity entity) {
        return WorkflowTaskPayload.builder()
                .id(entity.getId())
                .status(entity.getStatus())
                .instanceId(entity.getInstanceId())
                .updatedAt(entity.getUpdatedAt())
                .build();
    }
}
